import request from '@/utils/request'

const api = {
  project: '/project/',
  userClient: '/project/createUserClientInfo/',
  updateUserClient: '/project/',
  listUserClient: '/project/listUserClientInfo/',
  userSurety: '/project/createUserSurety/',
  listUserSurety: '/project/listUserSurety/',
  updateUserSurety: '/project/updateUserSurety/',
  deleteSurety:'/project/deleteUserSurety/',
  userLawyer: '/project/createUserLawyer/',
  updateUserLawyer: '/project/',
  listUserLawyer: '/project/listUserLawyer/',
  createBuilder: '/project/createBuilder/',
  updateBuilder: '/project/',
  listBuilder: '/project/listBuilder/',
  finish: '/project/projectCreateFinish/',
  loanData: '/loanData/',
  createHouse: '/project/createHouse/',
  updateHouse: '/project/updateHouse/',
  listHouse: '/project/listHouse/',
  deleteHouse:'/project/deleteHouse/',
  file: '/file/',
  getprojectList: '/project/projectList/',
  getprojectDetail: '/project/projectDetailInfo/',
  remarks: '/remarks/',
  withdraw: '/withdraw/',
  moneyarrange: '/moneyarrange/',
  repay: '/repay/',
  repayDetail: '/repay/getByProjectId/',
  repayState: '/repay/getLastInterestDate/',
  historyRate: '/historyRate/',
  interest: '/interest/InterestApportionList/',
  loanDetail: '/interest/listCompoundInterest/',
  addLoan:'/loanAdd/',
  loanDelay:'/loanDelay/',
  getAddr:'/project/projectAddrList/',
  sysUsers:'/sysUsers/',
  default:'/default/',
  defaultState:'/default/getRepayLastDay/',
  calc:'/default/listDefaultProject/',
  month:'/default/getProjectDate/',
  amount:'/default/getDefaultDetailAmount/',
  execute:'/default/executeListDefaultProject/',
  stationLetterTemp:'/stationLetterTemp/',
  role:'/role/',
  searchTop:'/project/searchTop/',
  userInfo:'/user/info/',
  history:'/historyRecord/',
  notice:'/notice/',
  feeData:'/default/getFeeData/',
  richText:'/richText/',
  richTextSave:'/richText/saveText/',
  statistics:'/statistics/getProjectStatistics/',
  lineChart:'/statistics/getLineChart/',
  repayment:'/statistics/repaymentStatistics/',
  createYear:'/statistics/createYearTarget/',
  // getYear:'/statistics/getYearTarget/',
  cashFlow:'/statistics/getYearTargetAndCash/',
  cashPercent:'/statistics/createCashPercent/',
  algorithm:'/statistics/getAlgorithmStatistics/',
  login:'/loginLog/',
  access:'/accessLog/',
}
//顶部搜索
export async function getsearch (params) {
  return await request.get(api.searchTop, {
    params
  })
}
//消息提示
export async function getNotice (params) {
  return await request.get(api.notice, {
    params
  })
}
export async function updateNotice (id, data) {
  return await request.put(`${api.notice + id}/`, data)
}
export async function deleteNotice (id) {
  return await request.delete(`${api.notice + id}/`)
}
//个人中心
export async function getUserInfo (params) {
  return await request.get(api.userInfo, {
    params
  })
}
//历史记录
export async function createHistory (data) {
  return await request.post(api.history, data)
}
export async function getHistory (params) {
  return await request.get(api.history, {
    params
  })
}
//商机审批
export async function approve (id, data) {
  return await request.put(`${api.project + id}/`, data)
}
//资金安排审批
export async function moneyApprove (id, data) {
  return await request.put(`${api.moneyarrange + id}/`, data)
}
// 项目简介
export async function createProject (data) {
  return await request.post(api.project, data)
}
export async function getProject (params) {
  return await request.get(api.project, {
    params
  })
}
export async function deleteProjectById (id) {
  return await request.delete(`${api.project + id}/`)
}
export async function getProjectById (id) {
  return await request.get(`${api.project + id}/`)
}
export async function updateProjectById (id, data) {
  return await request.put(`${api.project + id}/`, data)
}

// 客户资料
export async function createUserClient (data) {
  return await request.post(api.userClient, data)
}
export async function getUserClient (id) {
  return await request.get(api.listUserClient, {
    params: {
      projectId: id,
    }
  })
}
export async function updateUserClientById (id, data) {
  return await request.put(`${api.updateUserClient + id}/updateUserClientInfo/`, data)
}

//担保人
export async function createUserSurety (data) {
  return await request.post(api.userSurety, data)
}
export async function deleteUserSurety (id) {
  return await request.post(api.deleteSurety,{
      id,
  })
}
export async function getUserSurety (id) {
  return await request.get(api.listUserSurety, {
    params: {
      projectId: id,
    }
  })
}
export async function updateUserSuretyById (data) {
  return await request.post(api.updateUserSurety, data)
}

//律师资料
export async function createUserLawyer (data) {
  return await request.post(api.userLawyer, data)
}
export async function getUserLawyer (id) {
  return await request.get(api.listUserLawyer, {
    params: {
      projectId: id,
    }
  })
}
export async function updateUserLawyerById (id, data) {
  return await request.put(`${api.updateUserLawyer + id}/updateUserLawyer/`, data)
}

// 建筑商资料
export async function createBuilder (data) {
  return await request.post(api.createBuilder, data)
}
export async function getBuilder (id) {
  return await request.get(api.listBuilder,{
    params: {
      projectId: id,
    }
  })
}
export async function updateBuilderById (id, data) {
  return await request.put(`${api.updateBuilder + id}/updateBuilder/`, data)
}

// 贷款资料
export async function createloanData (data) {
  return await request.post(api.loanData, data)
}
export async function getloanData (id, type) {
  return await request.get(api.loanData, {
    params: {
      projectId: id,
      dataType: type
    }
  })
}
export async function updateloanDataById (data) {
  return await request.post(`${api.loanData}updateLoanData/`, data)
}

//项目建筑信息
export async function createHouse (data) {
  return await request.post(api.createHouse, data)
}
export async function getHouse (id, type) {
  return await request.get(api.listHouse, {
    params: {
      projectId: id,
      dataType: type
    }
  })
}
export async function updateHouseById (data) {
  return await request.post(api.updateHouse, data)
}
export async function deleteHouse (id) {
  return await request.delete(`${api.deleteHouse+id}/`)
}
//完成创建
export async function updateFinish (data) {
  return await request.post(api.finish, data)
}

//创建文件
export async function creatFile (data) {
  return await request.post(api.file, data)
}
export async function getFile (params) {
  return await request.get(api.file, { params })
}
export async function deleteFile (id) {
  return await request.delete(`${api.file + id}/`)
}

//项目列表
export async function getList (params) {
  return await request.get(api.getprojectList, {
    params
  })
}
//项目细节
export async function getDetailList (id) {
  return await request.get(api.getprojectDetail, {
    params: {
      projectId: id,
    }
  })
}
//还款明细
export async function getRepayDeatail (params) {
  return await request.get(api.repayDetail, {
    params
  })
}
//利息分摊
export async function getInterest (params) {
  return await request.get(api.interest, {
    params
  })
}
//贷款明细
export async function getLoanDetails (params) {
  return await request.get(api.loanDetail, {
    params
  })
}

//备注
export async function addRemarks (data) {
  return await request.post(api.remarks, data)
}
export async function getaLoneRemarks (id) {
  return await request.get(`${api.remarks + id}/`)
}
export async function getRemarks (projectId) {
  return await request.get(api.remarks, {
    params: {
      projectId,
    }
  })
}
export async function modifyRemarks (id, data) {
  return await request.put(`${api.remarks + id}/`, data)
}
export async function deleteRemarks (id) {
  return await request.delete(`${api.remarks + id}/`)
}

//提款请求
export async function createWithdraw (data) {
  return await request.post(api.withdraw, data)
}
export async function getWithdrawSingle (id) {
  return await request.get(`${api.withdraw + id}/`)
}
export async function reviseWithdraw (id,data) {
  return await request.put(`${api.withdraw + id}/`,data)
}
export async function getWithdraw (params) {
  return await request.get(api.withdraw, {
    params
  })
}
export async function deleteWithdraw (id) {
  return await request.delete(`${api.withdraw + id}/`)
}
//新增资金安排
export async function createMoneyarrange (data) {
  return await request.post(api.moneyarrange, data)
}
export async function getMoneyarrange () {
  return await request.get(api.moneyarrange)
}

//还款
export async function getRepayState (params) {
  return await request.get(api.repayState, {
    params
  })
}
export async function createRepay (data) {
  return await request.post(api.repay, data)
}
export async function getRepay (params) {
  return await request.get(api.repay, {
    params
  })
}
export async function getSingleRepay (id) {
  return await request.get(`${api.repay+ id}/`)
}
export async function updataRepay (id,data) {
  return await request.put(`${api.repay + id}/`,data)
}
export async function deleteRepay (id) {
  return await request.delete(`${api.repay + id}/`)
}
// 历史汇率
export async function getHistoryRate (params) {
  return await request.get(api.historyRate, {
    params
  })
}
//登录日志
export async function getLogin (params) {
  return await request.get(api.login, {
    params
  })
}
//操作日志
export async function getAccess (params) {
  return await request.get(api.access, {
    params
  })
}

//项目地址
export async function getAddr () {
  return await request.get(api.getAddr)
}
//加贷
export async function creatAddLoan(data){
  return await request.post(api.addLoan,data)
}
export async function updataAddLoan (id,data) {
  return await request.put(`${api.addLoan + id}/`,data)
}
export async function getAddLoan (params) {
  return await request.get(api.addLoan, {
    params
  })
}
export async function deleteAddLoan (id) {
  return await request.delete(`${api.addLoan + id}/`)
}

//延期
export async function creatLoanDelay(data){
  return await request.post(api.loanDelay,data)
}
export async function updataloanDelay (id,data) {
  return await request.put(`${api.loanDelay + id}/`,data)
}
export async function getloanDelay (params) {
  return await request.get(api.loanDelay, {
    params
  })
}
export async function deleteloanDelay (id) {
  return await request.delete(`${api.loanDelay + id}/`)
}


//违约计算列表
export async function getCalc (params) {
  return await request.get(api.calc, {
    params
  })
}
export async function getDefaultState (params) {
  return await request.get(api.defaultState, {
    params
  })
}
//违约计算月份
export async function getMonth (params) {
  return await request.get(api.month, {
    params
  })
}
//违约计算金额
export async function getAmount (params) {
  return await request.get(api.amount, {
    params
  })
}
//违约计算内容
export async function getFeeData (params) {
  return await request.get(api.feeData, {
    params
  })
}
//创建违约
export async function createDfault(data){
  return await request.post(api.default,data)
}

export async function getDfault (params) {
  return await request.get(api.default, {
    params
  })
}
export async function updataDfault (id,data) {
  return await request.put(`${api.default + id}/`,data)
}

export async function deleteDfault (id) {
  return await request.delete(`${api.default + id}/`)
}

//违约执行
export async function getExecute (params) {
  return await request.get(api.execute, {
    params
  })
}

export async function createStationLetterTemp(data){
  return await request.post(api.stationLetterTemp,data)
}
export async function getStationLetterTemp (params) {
  return await request.get(api.stationLetterTemp, {
    params
  })
}
export async function updataStationLetterTemp (id,data) {
  return await request.put(`${api.stationLetterTemp + id}/`,data)
}
//用户
export async function creatSysUser(data){
  return await request.post(api.sysUsers,data)
}
export async function updataSysUser (id,data) {
  return await request.put(`${api.sysUsers + id}/`,data)
}
export async function getOnlySysUser (id) {
  return await request.get(`${api.sysUsers + id}/`)
}
export async function getSysUser (params) {
  return await request.get(api.sysUsers, {
    params
  })
}
export async function deleteSysUser (id) {
  return await request.delete(`${api.sysUsers + id}/`)
}
//角色
export async function creatRole(data){
  return await request.post(api.role,data)
}
export async function updataRole (id,data) {
  return await request.put(`${api.role + id}/`,data)
}
export async function getOnlyRole (id) {
  return await request.get(`${api.role + id}/`)
}
export async function getRole (params) {
  return await request.get(api.role, {
    params
  })
}
export async function deleteRole (id) {
  return await request.delete(`${api.role + id}/`)
}
//数据分析
//筛选
export async function getStatistics (params) {
  return await request.get(api.statistics,{
    params
  })
}
//折线图
export async function getLineChart (params) {
  return await request.get(api.lineChart,{
    params
  })
}
//全年目标
export async function getYearTarget (params) {
  return await request.get(api.getYear,{
    params
  })
}
export async function createYearTarget (data) {
  return await request.post(api.createYear, data)
}
//现金流
export async function getCashFlow (params) {
  return await request.get(api.cashFlow,{
    params
  })
}
//算法
export async function getAlgorithm (params) {
  return await request.get(api.algorithm,{
    params
  })
}
export async function createCashPercent (data) {
  return await request.post(api.cashPercent, data)
}
//全年还款表
export async function getRepayment (params) {
  return await request.get(api.repayment,{
    params
  })
}

// 富文本
export async function createRichText (data) {
  return await request.post(api.richTextSave, data)
}
// export async function updateRichText (data) {
//   return await request.post(api.richText, data)
// }
export async function getRichText (params) {
  return await request.get(api.richText, { params })
}
// export async function deleteRichText (id) {
//   return await request.delete(`${api.richText + id}/`)
// }